from typing import List
import heapq

class Solution:
    def maxSubsequence(self, nums: List[int], k: int) -> List[int]:
        h = []
        for i, v in enumerate(nums):
            heapq.heappush(h, (v, i))
            if len(h) > k:
                heapq.heappop(h)
        h.sort(key=lambda x: x[1])
        return [x[0] for x in h]